/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cn.ekuma.epos.datalogic;


import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.table.TableDefinition;
import com.openbravo.data.loader.query.QBFParameters;
import com.openbravo.bean.crm.contract.Contract;
import com.openbravo.bean.crm.contract.ContractFollow;
import com.openbravo.bean.crm.service.Telephone;
import com.openbravo.bean.crm.service.TelephoneFollow;
import com.openbravo.bean.erp.Order;
import com.openbravo.bean.erp.viewbean.OrderLineConsultInfo;
import com.openbravo.bean.erp.OperationProductCategory;
import com.openbravo.bean.erp.OrderRelation;
import com.openbravo.bean.erp.OrderState;
import com.openbravo.bean.erp.OrderType;
import com.openbravo.bean.BusinessPartner;
import com.openbravo.bean.PaymentsLine;
import com.openbravo.bean.Product;
import com.openbravo.bean.ProductCustomerCategoryPrice;
import com.openbravo.bean.ProductReserve;
import com.openbravo.bean.SharedProduct;
import com.openbravo.bean.erp.viewbean.CustomerCategoryTransaction;
import com.openbravo.bean.erp.viewbean.CustomerTransaction;
import com.openbravo.bean.erp.viewbean.FinanceChargeAnysisInfo;
import com.openbravo.bean.erp.viewbean.FindOrdersInfo;
import com.openbravo.bean.erp.viewbean.FrontProductAnalysisInfo;
import com.openbravo.bean.erp.viewbean.OrderLine_V;
import com.openbravo.bean.erp.viewbean.ProductAnalysis;
import com.openbravo.bean.erp.viewbean.ProductCategoryAnalysisInfo;
import com.openbravo.bean.erp.viewbean.ProductCategoryTransaction;
import com.openbravo.bean.erp.viewbean.ProductTransaction;
import com.openbravo.bean.erp.TimeStore;
import com.openbravo.bean.oa.Attence;
import com.openbravo.bean.sales.TicketLine;
import com.openbravo.bean.sales.TicketLine_V;
import com.openbravo.bean.sales.TicketsInfo;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 *
 * @author Administrator
 */
public interface I_DataLogicERP extends I_DataLogicSales {
	public final static int TABLE_Base=1;
	public final static int TABLE_Erp=2;
	public final static int TABLE_Crm=3;
	public final static int TABLE_All=4;
	

    Integer getNextOrderIndex() throws BasicException;

    Integer getNextOrderRefundIndex() throws BasicException;

    void saveOrder(Order Order) throws BasicException;

    public Order loadOrder(String orderid) throws BasicException;

    void deleteOrder(final Order order) throws BasicException;

    void createTimeStoreLines(TimeStore timeStore) throws BasicException;

    void deleteTimeStoreLines(TimeStore timeStore) throws BasicException;

    Double getProductUnitsInOrder(String orderId, String productId, String attribinst) throws BasicException;

    Double getProductUnitsInTimeStore(String timeStoreId, String productId, String attribinst) throws BasicException;

    Double getProductUnitsInRealStore(String location, String productId, String attribinst) throws BasicException;

    List listBuildedTimeStore() throws BasicException;

    List<OrderLineConsultInfo> listConsultInfoByOrder(String orderId) throws BasicException;

    List<OrderLineConsultInfo> listConsultInfoByTimeStore(String timeStoreId) throws BasicException;

    List<OrderLineConsultInfo> listConsultInfoByRealStore(String locationId) throws BasicException;

    List<OrderLineConsultInfo> listConsultInfoByRealStore(String locationRef, String customerId) throws BasicException;

    List<OrderRelation> listOrderRelationInfoByOrder(String Id) throws BasicException;

    List<OrderRelation> listOrderRelationInfoByRefOrder(String Id) throws BasicException;

    OrderType findOrderTypeById(String id) throws BasicException;

    List<OrderState> listOrderStateByOrder(String id) throws BasicException;

    void saveSharedProduct(SharedProduct p) throws BasicException;

    //void deleteSharedProduct(List<SharedProduct> p) throws BasicException;

    List<ProductCustomerCategoryPrice> list(String productId) throws BasicException;

    List<ProductTransaction> productTransactionListQBF(Object filter) throws BasicException;

    List<ProductTransaction> productPOSTransactionListQBF(Object filter) throws BasicException;

    List<OrderLine_V> productTransactionDialyListQBF(Object filter) throws BasicException;

    List<OrderLine_V> productPOSTransactionDialyListQBF(Object filter) throws BasicException;

    
    ProductReserve getProductReserveByCode(String sCode) throws BasicException;
    
    List<ProductReserve> listProductReserveBySimilarCode(String code) throws BasicException;
    
    List<OperationProductCategory> listOperationProductCategoryByProduct(String productId)throws BasicException;
    
    List<FindOrdersInfo> listOrderInfoByAnlysis(Object filter) throws BasicException;
    
    List<Product> listByOperationCategory(String operationCategoryId)throws BasicException;
    
    List<Product> listProductByErrorPrice() throws BasicException ;
    
    List<Product> listProductByBOM() throws BasicException;
    
    List<Product> listProductByProfits(double form,double to) throws BasicException;

	Order loadLinkOrder(String id) throws BasicException;
	
	List<ProductCategoryTransaction> productCategoryTransactionListQBF(Object filter) throws BasicException;
	 
	List<ProductCategoryTransaction> productCategoryPOSTransactionListQBF(Object filter) throws BasicException;

	List<CustomerCategoryTransaction> customerCategoryTransactionListQBF(
			Object[] filter1)throws BasicException;

	List<CustomerCategoryTransaction> customerCategoryPOSTransactionListQBF(
			Object[] filter1)throws BasicException;

	List<BusinessPartner> listCustomerByOperationCategory(String id)throws BasicException;

	List<CustomerTransaction> customerTransactionListQBF(
			QBFParameters transactionFilter)throws BasicException;

	List<CustomerTransaction> customerPOSTransactionListQBF(
			QBFParameters transactionFilter)throws BasicException;
	
	public List<FindOrdersInfo> listShardOrder(Object filter) throws BasicException;
	
	public List<TicketsInfo> listByTicketId(String id) throws BasicException ;
	
	void updateTelephone( Telephone parent,TelephoneFollow follow)throws BasicException;

	void updateContract(Contract obj, ContractFollow contractFollow)throws BasicException;
	
	List<ProductAnalysis> listProductAnalysisByCustomer(String location,String customer) throws BasicException;
	
	List<ProductAnalysis> listProductAnalysisByProductCurDate(Date startDate, Date endDate) throws BasicException;

	Double findCustomerCategoryWholesalePrice(String productId, String categoryid) throws BasicException;

	HashMap findOrderRulePropByNameAndOrderType(String orderTypeId,
			String ruleName)throws BasicException;
	

	List<String> findOrderSuperedRuleByOrderType(String orderTypeId)throws BasicException;

	List<TicketLine_V> listSaleManTicketLine(Object[] beforeFilterParas)throws BasicException;
	
	public List<PaymentsLine> listPayments(FinanceChargeAnysisInfo info,Object filter)throws BasicException;


	HashMap findOrderProcessPropByNameAndOrderType(String orderTypeId,
			String processName)throws BasicException;
	
	public List<String> findOrderSuperedProcessByOrderType(String orderTypeId) throws BasicException;
	
	List<ProductCategoryAnalysisInfo> listPosCategoryAnalysisInfo(Object filter) throws BasicException;

	Order getSharedOrder(String Id) throws BasicException;
	
	public List<FindOrdersInfo> listOrderInfo(Object filter) throws BasicException;
	
	Attence attence(String userId,String attenceName)throws BasicException;
	
	void doBackDb() throws BasicException;
	
	void restoreDb() throws BasicException;
	
	List<TableDefinition> getImpExpTableList(int type);
	
	void doExportTableDateDb(List<TableDefinition> exportTales,Date start,Date end) throws BasicException;

	List<FrontProductAnalysisInfo> listFrontProductAnalysisByCustomer(String location, String customer, Date startTime,
			Date endTime) throws BasicException;

	List<FrontProductAnalysisInfo> listFrontProductAnalysisByNewProducts(String location, Date startDate, Date endDate,
			Date date, Date date2)throws BasicException ;
	
	List<FrontProductAnalysisInfo> listFrontProductAnalysisByProductSimilarCode(String locatin, String product,
			Date startTime, Date endTime)throws BasicException;

    void updateOrderState(String id, String afterState)throws BasicException;

	void updateOrderDebt(String id, double cash)throws BasicException;
}
